﻿using System;
using QuickTest.Core.Compilation;
using QuickTest.Core.TestRunner;

namespace QuickTest.Core.Events
{
    [Serializable]
    public class EventHub : MarshalByRefObject, IEventHub
    {
        public event EventHandler<EventArgs> TestRunExecuted = delegate { };
        public event EventHandler<CompileStartedEventArgs> CompileStarted = delegate { };
        public event EventHandler<CompileFinishedEventArgs> CompileFinished = delegate { };
        public event EventHandler<CompileErrorEventArgs> CompileError = delegate { };
        public event EventHandler<TestRunStartedEventArgs> RunStarted = delegate { };
        public event EventHandler<TestEventArgs> TestFinished = delegate { };
        public event EventHandler<TestRunFinishedEventArgs> RunFinished = delegate { };

        public void RaiseCompileStarted(CompileStartedEventArgs e)
        {
            CompileStarted(this, e);
        }

        public void RaiseCompileFinished(CompileFinishedEventArgs e)
        {
            CompileFinished(this, e);
        }

        public void RaiseCompileError(CompileErrorEventArgs e)
        {
            CompileError(this, e);
        }

        public void RaiseRunStarted(TestRunStartedEventArgs e)
        {
            RunStarted(this, e);
        }

        public virtual void RaiseTestFinished(TestEventArgs e)
        {
            TestFinished(this, e);
        }

        public void RaiseRunFinished(TestRunFinishedEventArgs e)
        {
            RunFinished(this, e);
        }

        public void RaiseTestRunExecuted(EventArgs e)
        {
            TestRunExecuted(this, e);
        }
    }
}
